package com.cloudkinto.service.order.outbound;

import com.baomidou.mybatisplus.extension.service.IService;
import com.cloudkinto.bo.order.allocate.AllocateCancelAddBo;
import com.cloudkinto.bo.order.allocate.AllocateCancelQueryBo;
import com.cloudkinto.bo.order.allocate.BackAllocateShelfBo;
import com.cloudkinto.bo.order.outbound.BackOutboundShelfBo;
import com.cloudkinto.bo.order.outbound.OutboundCancelAddBo;
import com.cloudkinto.bo.order.outbound.OutboundCancelQueryBo;
import com.cloudkinto.common.web.PageResult;
import com.cloudkinto.common.web.SingleResult;
import com.cloudkinto.entity.*;
import com.cloudkinto.enumType.order.outbound.OutboundOrderKind;
import com.cloudkinto.service.consumer.vo.order.PlatformOrderCancelReq;
import com.cloudkinto.vo.common.CommonBatchOperationVo;
import com.cloudkinto.vo.order.allocate.BackAllocateShelfVo;
import com.cloudkinto.vo.order.outbound.BackOutboundShelfVo;
import com.cloudkinto.vo.storage.StorageLocationVo;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 出库单截单 service接口
 * </p>
 *
 * @author long
 * @since 2024-12-09
 */
public interface OutboundCancelService extends IService<OutboundCancelDo> {
    void add(PlatformOrderCancelReq req);

    CommonBatchOperationVo add(OutboundCancelAddBo req, Long userId, String username);

    CommonBatchOperationVo allocateAdd(AllocateCancelAddBo req, Long userId, String username);

    SingleResult pageInit(Long userId, Long tenantId);

    PageResult getListPage(OutboundCancelQueryBo bo);

    PageResult getAllocateListPage(AllocateCancelQueryBo bo);

    SingleResult markFail(Long id, Long userId, String username);

    SingleResult allocateMarkFail(Long id, Long userId, String username);

    SingleResult backOutboundShelf(BackOutboundShelfBo req, Long userId, String username);

    void backOutboundShelfAfterHandler(Long userId, String username, OutboundCancelDo cancelDo, OrderOutboundDo outboundDo, List<OrderOutboundProductDo> outboundProductDoList, List<OutboundPickingDo> pickingDoList, Map<Long, StorageLocationVo> cellIdMatchDo, Map<Long, ProductDo> productIdMatch);

    /**
     * 一件代发出库单截单后的操作
     *
     * @param outboundDo
     * @param userId
     * @param outboundProductIdList
     */
    void outboundCancelAfterHandler(OrderOutboundDo outboundDo, Long userId, List<Long> outboundProductIdList);

    SingleResult backAllocateShelf(BackAllocateShelfBo bo, Long userId, String username);

    void backAllocateShelfAfterHandler(Long userId, String username, OutboundCancelDo cancelDo, AllocatePlanDo planDo, List<AllocatePlanItemDo> planItemDoList, List<OutboundPickingDo> pickingDoList, Map<Long, StorageLocationVo> cellIdMatchDo, Map<Long, ProductDo> productIdMatch);

    BackOutboundShelfVo getBackOutboundDetail(Long id);

    BackAllocateShelfVo getBackAllocateDetail(Long id);

    SingleResult listPageStatusSta(OutboundCancelQueryBo bo);

    SingleResult allocateListPageStatusSta(AllocateCancelQueryBo bo);


    CommonBatchOperationVo batchBackOutboundShelf(List<Long> ids, Long userId, String username);

    CommonBatchOperationVo batchMarkFail(List<Long> ids, OutboundOrderKind orderKind, Long userId, String username);

    CommonBatchOperationVo batchBackAllocateShelf(List<Long> ids, Long userId, String username);
}
